/*
 * @(#)MaintFormDataForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.form.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.form.bean.FormData;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;

/**
  MaintFormDataForm.java

  This class is the for web form purpose.

  @author      Scott Tong
  @company     DCIVision Limited
  @creation date   07/01/2004
  @version     $Revision: 1.3 $
*/

public class MaintFormDataForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.3 $";

  private String dataElementID = null;
  private String dataString = null;
  private String dataNumeric = null;
  private String dataDatetime = null;

  public MaintFormDataForm() {
    super();
  }

  public String getDataElementID() {
    return(this.dataElementID);
  }

  public void setDataElementID(String dataElementID) {
    this.dataElementID = dataElementID;
  }

  public String getDataString() {
    return(this.dataString);
  }

  public void setDataString(String dataString) {
    this.dataString = dataString;
  }

  public String getDataNumeric() {
    return(this.dataNumeric);
  }

  public void setDataNumeric(String dataNumeric) {
    this.dataNumeric = dataNumeric;
  }

  public String getDataDatetime() {
    return(this.dataDatetime);
  }

  public void setDataDatetime(String dataDatetime) {
    this.dataDatetime = dataDatetime;
  }
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setDataElementID(null);
    this.setDataString(null);
    this.setDataNumeric(null);
    this.setDataDatetime(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    FormData tmpFormData = new FormData();
    tmpFormData.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpFormData.setDataElementID(TextUtility.parseIntegerObj(this.getDataElementID()));
    tmpFormData.setDataString(this.getDataString());
    tmpFormData.setDataNumeric(TextUtility.parseFloatObj(this.getDataNumeric()));
    tmpFormData.setDataDatetime(parseTimestamp(this.getDataDatetime()));
    tmpFormData.setRecordStatus(this.getRecordStatus());
    tmpFormData.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpFormData.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpFormData.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpFormData.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpFormData.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpFormData;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    FormData tmpFormData = (FormData)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpFormData.getID()));
    this.setDataElementID(TextUtility.formatIntegerObj(tmpFormData.getDataElementID()));
    this.setDataString(tmpFormData.getDataString());
    this.setDataNumeric(TextUtility.formatFloatObj(tmpFormData.getDataNumeric()));
    this.setDataDatetime(formatTimestamp(tmpFormData.getDataDatetime()));
    this.setRecordStatus(tmpFormData.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpFormData.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpFormData.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpFormData.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpFormData.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpFormData.getUpdateDate()));
  }
}
